package com.zbbt.sportslottery.ui.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.zxing.WriterException;
import com.zbbt.sportslottery.R;
import com.zbbt.sportslottery.app.Constant;
import com.zbbt.sportslottery.ui.widget.saoyisao.EncodingHandler;
/**
 * 
 * @ClassName: HDQInfoActivity
 * @Description: 活动详情页
 * @author：GaomingShuo
 * @date：2015-3-5 下午2:51:25     
 * @version V1.0
 */
public class HDQInfoActivity extends SimpleBaseActivity{

	private ImageView qrcode_img;
	private TextView dhm_code_tx;
	private String code_str;
	private String all_str;
	private LinearLayout gomap_btn;

	@Override
	protected void onActivityCreated(Bundle savedInstanceState) {
		setContentView(R.layout.activity_drcode);
		code_str = getIntent().getStringExtra("dhm_code");
		all_str = getIntent().getStringExtra("all_str");
	}

	@Override
	protected void initView() {
		qrcode_img = (ImageView) findViewById(R.id.qrcode_img);
		dhm_code_tx = (TextView) findViewById(R.id.dhm_code_tx);
		gomap_btn = (LinearLayout) findViewById(R.id.gomap_btn);
		initData();
	}

	@Override
	protected void setListener() {
		gomap_btn.setOnClickListener(this);
	}

	@Override
	protected void onClickEvent(View v) {
		switch (v.getId()) {
		case R.id.gomap_btn:
			Intent intentL = new Intent(context, LotteryShopActivity.class);
			intentL.putExtra("isOpen", Constant.isShopIsopen);
			startActivity(intentL);
			break;
		}
	}

	protected void initData() {
		dhm_code_tx.setText(code_str);
		Bitmap qrCodeBitmap;
		try {
			qrCodeBitmap = EncodingHandler.createQRCode(all_str, 400);
			qrcode_img.setImageBitmap(qrCodeBitmap);
		} catch (WriterException e) {
			e.printStackTrace();
		}
	}

}
